package com.zzh.student.dao;

import com.zzh.ssi.frame.base.BaseDao;
import com.zzh.ssi.frame.util.PageInfo;
import com.zzh.student.dt.StudentDt;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * Date: 13-1-10
 * Time: 下午3:59
 * To change this template use File | Settings | File Templates.
 */
public class StudentDao extends BaseDao {
    public int add(StudentDt dt) throws SQLException {
        return this.getSqlMapClient().update("studentSql.insert", dt);
    }

    public List query(StudentDt dt, PageInfo pageInfo) throws SQLException {
        pageInfo.setTotalRows((Integer) this.getSqlMapClient().queryForObject("studentSql.queryForCount", dt));
        dt.setSplitPageSql(pageInfo);
        return this.getSqlMapClient().queryForList("studentSql.queryStudent", dt);
    }

    public int delete(StudentDt dt) throws SQLException {
        return this.getSqlMapClient().update("studentSql.delete", dt);
    }

    public int update(StudentDt dt) throws SQLException {
        return this.getSqlMapClient().update("studentSql.update", dt);
    }

    public StudentDt queryById(StudentDt dt) throws SQLException {
        return (StudentDt) this.getSqlMapClient().queryForObject("studentSql.queryById", dt);
    }
}
